﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web;

namespace Bundler
{
    public class PageCompressorModule : IHttpModule
    {
        private const string ContentEncoding = "Content-Encoding";

        #region Public Methods and Operators

        public void Dispose()
        {
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += OnContextBeginRequest;
        }

        #endregion

        #region Methods

        private static void OnContextBeginRequest(object sender, EventArgs e)
        {
            if (sender == null)
                throw new ArgumentNullException("sender");

            var context = sender as HttpApplication;
            if(context == null)
                throw new ApplicationException("sender is not of type HttpApplication");

            GzipCompression.Compress(context.Context);
        }
       

        #endregion
    }
}
